home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / domácnost a kancelar / opencontacts / setup.exe / {app} / DataSet / Templates / hCard.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2007-08-19  |  14.7 KB  |  358 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <!--Convert Open Contacts' XML into HTML with hCard tags. You may copy/past the result into your Web pages.
  3. In order to publish public info only with privacy concern, you may comment out some XML codes or simply remove
  4. some HTML results.
  5.  
  6. This file is useful for publishing selected contact info to the Web pages.
  7. -->
  8. <xsl:stylesheet version="1.0"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  10.   <xsl:output method="html" omit-xml-declaration="yes" encoding="UTF-8" />
  11.  
  12.   <xsl:template match="/">
  13.     <html>
  14.  
  15.       <body>
  16.         <xsl:for-each select="OpenContacts/Contacts/Contact">
  17.           <div class="vcard">
  18.             <table border="0" width="100%" id="table2">
  19.               <tr>
  20.                 <td width="80%">
  21.                   <font face="Times New Roman" size="3">
  22.                     <b>
  23.                       <span class="fn">
  24.                         <xsl:value-of select="@Name"/>
  25.                       </span>
  26.                     </b>
  27.                   </font>
  28.                 </td>
  29.                 <td>
  30.                   <xsl:value-of select="@Title"/>
  31.                 </td>
  32.               </tr>
  33.             </table>
  34.             <div style="margin-left: 15px;">
  35.  
  36.               <font size="2" color="#800000">
  37.                 <xsl:apply-templates select="Notes"/>
  38.               </font>
  39.  
  40.  
  41.             </div>
  42. <!--You may pick up some fields to be published by absolute path rather than using for-each-->
  43.               <xsl:for-each select="Sections/Section">
  44.               <div style="margin-left: 15px;">
  45.  
  46.  
  47.                 <b>
  48.                   <font face="Times New Roman" size="2">
  49.                     <xsl:value-of select="@Name"/>
  50.                   </font>
  51.                 </b>
  52.               </div>
  53.  
  54. <!--You may test against field name or field action type-->
  55.               <table border="0" width="100%" id="table1" cellspacing="0" cellpadding="0">
  56.                 <xsl:for-each select="Fields/Field">
  57.                   <xsl:if test="not(@Action='map')">
  58.                     <tr>
  59.  
  60.                       <xsl:choose>
  61.                         <xsl:when test="@Action='email'">
  62.                           <td width="15"></td>
  63.                           <td width="80" bgcolor="#C3D9FF">
  64.                             <font face="Times New Roman" size="2">
  65.                               <xsl:value-of select="@Name"/>:
  66.                             </font>
  67.                           </td>
  68.                           <td bgcolor="#E0ECFF">
  69.                             <font size="3">
  70.                               <a class="email" href="mailto:{@Value}">
  71.                                 <xsl:value-of select="@Value"/>
  72.                               </a>
  73.                             </font>
  74.                           </td>
  75.                         </xsl:when>
  76.  
  77.                         <xsl:when test="@Action='web'">
  78.                           <td width="15"></td>
  79.                           <td width="80" bgcolor="#C3D9FF">
  80.                             <font face="Times New Roman" size="2">
  81.                               <xsl:value-of select="@Name"/>:
  82.                             </font>
  83.                           </td>
  84.                           <td bgcolor="#E0ECFF">
  85.                             <font size="3">
  86.                           <!--Case insensitive match is not big concern.-->
  87.                           <xsl:if test="starts-with(@Value, 'http://')">
  88.                               <a class="url" href="{@Value}">
  89.                                 <xsl:value-of select="@Value"/>
  90.                               </a>
  91.                           </xsl:if>
  92.                           <xsl:if test="not(starts-with(@Value, 'http://'))">
  93.                             <a class="url" href="http://{@Value}">
  94.                               <xsl:value-of select="@Value"/>
  95.                             </a>
  96.                           </xsl:if>
  97.                             </font>
  98.                           </td>
  99.                         </xsl:when>
  100.  
  101.                         <xsl:when test="@Action='phone'">
  102.                           <td width="15"></td>
  103.                           <td width="80" bgcolor="#C3D9FF">
  104.                             <font face="Times New Roman" size="2">
  105.                               <xsl:value-of select="@Name"/>:
  106.                             </font>
  107.                           </td>
  108.                           <td bgcolor="#E0ECFF">
  109.                             <font size="3">
  110.                               <span class="tel">
  111.                                 <xsl:value-of select="@Value"/>
  112.                               </span>
  113.                             </font>
  114.                           </td>
  115.                         </xsl:when>
  116.  
  117.  
  118.                         <!--You may render phone action type above to skype uri-->
  119.                         <xsl:when test="@Action='skype'">
  120.                           <td width="15"></td>
  121.                           <td width="80" bgcolor="#C3D9FF">
  122.                             <font face="Times New Roman" size="2">
  123.                               <xsl:value-of select="@Name"/>:
  124.                             </font>
  125.                           </td>
  126.                           <td bgcolor="#E0ECFF">
  127.                             <font size="3">
  128.                               <a href="skype:{@Value}">
  129.                                 <xsl:value-of select="@Value"/>
  130.                               </a>
  131.                             </font>
  132.                           </td>
  133.                         </xsl:when>
  134.  
  135.                         <xsl:when test="@Name='AIM'">
  136.                           <td width="15"></td>
  137.                           <td width="80" bgcolor="#C3D9FF">
  138.                             <font face="Times New Roman" size="2">
  139.                               <xsl:value-of select="@Name"/>:
  140.                             </font>
  141.                           </td>
  142.                           <td bgcolor="#E0ECFF">
  143.                             <font size="3">
  144.                               <a class="url" href="aim:goim?screenname={@Value}">
  145.                                 <xsl:value-of select="@Value"/>
  146.                               </a>
  147.                             </font>
  148.                           </td>
  149.                         </xsl:when>
  150.  
  151.                         <xsl:when test="@Name='Yahoo'">
  152.                           <td width="15"></td>
  153.                           <td width="80" bgcolor="#C3D9FF">
  154.                             <font face="Times New Roman" size="2">
  155.                               <xsl:value-of select="@Name"/>:
  156.                             </font>
  157.                           </td>
  158.                           <td bgcolor="#E0ECFF">
  159.                             <font size="3">
  160.                               <a class="url" href="ymsgr:sendIM?{@Value}">
  161.                                 <xsl:value-of select="@Value"/>
  162.                               </a>
  163.                             </font>
  164.                           </td>
  165.                         </xsl:when>
  166.  
  167.                         <xsl:when test="@Name='MSN'">
  168.                           <td width="15"></td>
  169.                           <td width="80" bgcolor="#C3D9FF">
  170.                             <font face="Times New Roman" size="2">
  171.                               <xsl:value-of select="@Name"/>:
  172.                             </font>
  173.                           </td>
  174.                           <td bgcolor="#E0ECFF">
  175.                             <font size="3">
  176.                               <a class="url" href="msnim:chat?contact={@Value}">
  177.                                 <xsl:value-of select="@Value"/>
  178.                               </a>
  179.                             </font>
  180.                           </td>
  181.                         </xsl:when>
  182.  
  183.                         <xsl:when test="@Name='ICQ'">
  184.                           <td width="15"></td>
  185.                           <td width="80" bgcolor="#C3D9FF">
  186.                             <font face="Times New Roman" size="2">
  187.                               <xsl:value-of select="@Name"/>:
  188.                             </font>
  189.                           </td>
  190.                           <td bgcolor="#E0ECFF">
  191.                             <font size="3">
  192.                               <a class="url" type="application/x-icq"
  193.    href="http://www.icq.com/people/cmd.php?uin=[{@Value}]&action=message">
  194.                                 <xsl:value-of select="@Value"/>
  195.                               </a>
  196.                             </font>
  197.                           </td>
  198.                         </xsl:when>
  199.  
  200.                         <xsl:when test="@Name='Title'">
  201.                           <td width="15"></td>
  202.                           <td width="80" bgcolor="#C3D9FF">
  203.                             <font face="Times New Roman" size="2">
  204.                               <xsl:value-of select="@Name"/>:
  205.                             </font>
  206.                           </td>
  207.                           <td bgcolor="#E0ECFF">
  208.                             <font size="3">
  209.                               <span class="title">
  210.                                 <xsl:value-of select="@Value"/>
  211.                               </span>
  212.                             </font>
  213.                           </td>
  214.                         </xsl:when>
  215.  
  216.                         <xsl:otherwise>
  217.                           <!--   Ohters not being published-->
  218.  
  219.                         </xsl:otherwise>
  220.                         
  221.                       </xsl:choose>
  222.  
  223.                     </tr>
  224.                   </xsl:if>
  225.                 </xsl:for-each>
  226.  
  227.                 <xsl:if test="count(Fields/Field[@Action='map']) > 0">
  228.                   <tr>
  229.                     <td width="15"></td>
  230.                     <td width="80" bgcolor="#C3D9FF">
  231.                       <font face="Times New Roman" size="2">
  232.                          
  233.                         <xsl:text>Address:</xsl:text>
  234.  
  235.                       </font>
  236.                     </td>
  237.  
  238.                     <td bgcolor="#E0ECFF">
  239.                       <font size="3">
  240.  
  241.                         <span class="adr">
  242.                           <xsl:if test="Fields/Field[@Name='Unit']">
  243.                             <span class="extended-address">
  244.                               <xsl:value-of select="Fields/Field[@Name='Unit']/@Value"/>
  245.                             </span>
  246.                           </xsl:if>
  247.                           
  248.                           <xsl:if test="Fields/Field[@Name='Geo']">
  249.                             <span class="geo">
  250.                               <span class="latitude">
  251.                                 <xsl:value-of select="substring-before(Fields/Field[@Name='Geo']/@Value, ',')"/>
  252.                               </span>,
  253.                               <span class="longitude">
  254.                               <xsl:value-of select="substring-after(Fields/Field[@Name='Geo']/@Value, ',')"/>
  255.                             </span>
  256.                             </span>
  257.                           </xsl:if>
  258.  
  259.                           <xsl:if test="Fields/Field[@Name='Address']">
  260.                             <span class="street-address">
  261.                               <xsl:value-of select="Fields/Field[@Name='Address']/@Value"/>
  262.                             </span>
  263.                           </xsl:if>
  264.  
  265.                           <xsl:if test="Fields/Field[@Name='Street']">
  266.                             <span class="street-address">
  267.                               <xsl:value-of select="Fields/Field[@Name='Street']/@Value"/>
  268.                             </span>
  269.                             <xsl:if test="Fields/Field[@Name='City']">, </xsl:if>
  270.                           </xsl:if>
  271.                           <xsl:if test="Fields/Field[@Name='City']">
  272.                             <span class="locality">
  273.                               <xsl:value-of select="Fields/Field[@Name='City']/@Value"/>
  274.                             </span>
  275.                             <xsl:if test="Fields/Field[@Name='State']">, </xsl:if>
  276.                           </xsl:if>
  277.                           <xsl:if test="Fields/Field[@Name='State']">
  278.                             <span class="region">
  279.                               <xsl:value-of select="Fields/Field[@Name='State']/@Value"/>
  280.                             </span>
  281.                             <xsl:if test="Fields/Field[@Name='Postcode']">
  282.                               <xsl:text> </xsl:text>
  283.                             </xsl:if>
  284.                           </xsl:if>
  285.                           <xsl:if test="Fields/Field[@Name='Postcode']">
  286.                             <span class="postal-code">
  287.                               <xsl:value-of select="Fields/Field[@Name='Postcode']/@Value"/>
  288.                             </span>
  289.                             <xsl:if test="Fields/Field[@Name='Country']">
  290.                               <xsl:text>, </xsl:text>
  291.                             </xsl:if>
  292.                           </xsl:if>
  293.                           <xsl:if test="Fields/Field[@Name='Country']">
  294.                             <span class="country-name">
  295.                               <xsl:value-of select="Fields/Field[@Name='Country']/@Value"/>
  296.                             </span>
  297.                           </xsl:if>
  298.                         </span>
  299.                       </font>
  300.                     </td>
  301.                   </tr>
  302.                 </xsl:if>
  303.               </table>
  304.  
  305.               <div class="note" style="margin-left: 15px;">
  306.  
  307.                 <font size="2" color="#800000">
  308.                   <xsl:apply-templates select="Notes"/>
  309.                 </font>
  310.  
  311.  
  312.               </div>
  313.             </xsl:for-each>
  314.  
  315.             <p>  </p>
  316.  
  317.           </div>
  318.         </xsl:for-each>
  319.  
  320.  
  321.  
  322.  
  323.  
  324.       </body>
  325.     </html>
  326.   </xsl:template>
  327.  
  328.  
  329.   <xsl:template match="Notes">
  330.     <xsl:call-template name="substitute">
  331.       <xsl:with-param name="string" select="." />
  332.     </xsl:call-template>
  333.   </xsl:template>
  334.  
  335.   <xsl:template name="substitute">
  336.     <xsl:param name="string" />
  337.     <xsl:param name="from" select="' '" />
  338.     <xsl:param name="to">
  339.       <p/>
  340.     </xsl:param>
  341.     <xsl:choose>
  342.       <xsl:when test="contains($string, $from)">
  343.         <xsl:value-of select="substring-before($string, $from)" />
  344.         <xsl:copy-of select="$to" />
  345.         <xsl:call-template name="substitute">
  346.           <xsl:with-param name="string"
  347.                           select="substring-after($string, $from)" />
  348.           <xsl:with-param name="from" select="$from" />
  349.           <xsl:with-param name="to" select="$to" />
  350.         </xsl:call-template>
  351.       </xsl:when>
  352.       <xsl:otherwise>
  353.         <xsl:value-of select="$string" />
  354.       </xsl:otherwise>
  355.     </xsl:choose>
  356.   </xsl:template>
  357.  
  358. </xsl:stylesheet>